<template>
  <div class="cell-wrap">
    <template v-for="btn in btnConfig">
      <el-button :key="btn.invalid" :type="btn.type" :disabled="getDisabled(btn)" v-hasPermi="btn.permi" @click="handleBtn(btn)">{{ btn.label }}</el-button>
    </template>
  </div>
</template>

<script>
export default {
  name: 'CellRender',
  methods: {
    handleBtn(btn) {
      this.params.context.componentParent.actionEvent(
        btn.invalid,
        this.params.data
      )
    },
    getDisabled(btn) {
      const type = typeof btn.disabled
      if (type == 'function') {
        return btn.disabled(this.params.data)
      } else if (type == 'boolean') {
        return btn.disabled
      } else {
        return false
      }
    }
  },
  computed: {
    btnConfig() {
      return this.params.colDef.btnConfig
    }
  },
  mounted() {}
}
</script>

<style lang="scss">
</style>